<?php

namespace view;

class StarSet {

    private $stars = array();

    public function __construct($mark, $starsCount, $starSize,$transparent=false) {
        $round = round($mark, 1);
        $int = intval($round);
        $percent = round(($round - $int) * 100, -1);
        for ($i = 0; $i < $int; $i++) {
            $this->stars[] = new Star($starSize, 1,0,$transparent);
        }
        if ($mark < $starsCount) {
            if ($percent < 50) {
                $this->stars[] = new Star($starSize, $percent / 100, 2,$transparent);
            } else {
                $this->stars[] = new Star($starSize, $percent / 100, 1,$transparent);
            }
            for ($i = $int + 1; $i < $starsCount; $i++) {
                $this->stars[] = new Star($starSize, 0, 2,$transparent);
            }
        }
    }

    public function __toString() {
        $result = "";
        foreach ($this->stars as $star) {
            $result.=$star->__toString() . "\n";
        }
        return $result;
    }

    //put your code here
}
